﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ZhonTai.Industry.Contracts.Core.Enums;

namespace ZhonTai.Industry.Contracts.Model.Entity
{
    public class DataShip
    {
        /// <summary>
        /// 工位ID
        /// </summary>
        public long StationId { get; set; }

        /// <summary>
        /// 工站代号
        /// </summary>
        public string OPCode { get; set; }

        /// <summary>
        /// PLC数据块
        /// </summary>
        public DB PLCDB { get; set; }

        /// <summary>
        /// MES数据块
        /// </summary>
        public DB MESDB { get; set; }
    }

    /// <summary>
    /// PLC数据块配置
    /// </summary>
    public struct DB
    {
        /// <summary>
        /// DB块地址
        /// </summary>
        public int DBAddress { get; set; }

        /// <summary>
        /// 数据点位
        /// </summary>
        public List<DBField> DataFields { get; set; }

        /// <summary>
        /// 订阅点位
        /// </summary>
        public List<DBField> KeyFields { get; set; }

        /// <summary>
        /// 起始偏移量
        /// </summary>
        public int StartOffset { get; set; }

        /// <summary>
        /// 数据块长度
        /// </summary>
        public ushort DBLength { get; set; }
    }

    public class DBField
    {
        /// <summary>
        /// 别名
        /// </summary>
        public string Another { get; set; }

        /// <summary>
        /// 偏移量类型
        /// </summary>
        public PLCDataTypeEnum PLCDataType { get; set; }

        /// <summary>
        /// 偏移量
        /// </summary>
        public double Offset { get; set; }

        /// <summary>
        /// 分组
        /// </summary>
        public string GroupName { get; set; }

        /// <summary>
        /// 主题
        /// </summary>
        public string Topic { get; set; }

        /// <summary>
        /// 描述
        /// </summary>
        public string Description { get; set; }

        /// <summary>
        /// 单位
        /// </summary>
        public string Unit { get; set; }
    }
}